1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.TextChildAnchor;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.Widget;
31 private import gtk.c.functions;
32 public  import gtk.c.types;
33 
34 
35 /**
36  * A `GtkTextChildAnchor` is a spot in a `GtkTextBuffer` where child widgets can
37  * be “anchored”.
38  * 
39  * The anchor can have multiple widgets anchored, to allow for multiple views.
40  */
41 public class TextChildAnchor : ObjectG
42 {
43 	/** the main Gtk struct */
44 	protected GtkTextChildAnchor* gtkTextChildAnchor;
45 
46 	/** Get the main Gtk struct */
47 	public GtkTextChildAnchor* getTextChildAnchorStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gtkTextChildAnchor;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)gtkTextChildAnchor;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GtkTextChildAnchor* gtkTextChildAnchor, bool ownedRef = false)
64 	{
65 		this.gtkTextChildAnchor = gtkTextChildAnchor;
66 		super(cast(GObject*)gtkTextChildAnchor, ownedRef);
67 	}
68 
69 
70 	/** */
71 	public static GType getType()
72 	{
73 		return gtk_text_child_anchor_get_type();
74 	}
75 
76 	/**
77 	 * Creates a new `GtkTextChildAnchor`.
78 	 *
79 	 * Usually you would then insert it into a `GtkTextBuffer` with
80 	 * [method@Gtk.TextBuffer.insert_child_anchor]. To perform the
81 	 * creation and insertion in one step, use the convenience
82 	 * function [method@Gtk.TextBuffer.create_child_anchor].
83 	 *
84 	 * Returns: a new `GtkTextChildAnchor`
85 	 *
86 	 * Throws: ConstructionException GTK+ fails to create the object.
87 	 */
88 	public this()
89 	{
90 		auto __p = gtk_text_child_anchor_new();
91 
92 		if(__p is null)
93 		{
94 			throw new ConstructionException("null returned by new");
95 		}
96 
97 		this(cast(GtkTextChildAnchor*) __p, true);
98 	}
99 
100 	/**
101 	 * Creates a new `GtkTextChildAnchor` with the given replacement character.
102 	 *
103 	 * Usually you would then insert it into a `GtkTextBuffer` with
104 	 * [method@Gtk.TextBuffer.insert_child_anchor].
105 	 *
106 	 * Returns: a new `GtkTextChildAnchor`
107 	 *
108 	 * Since: 4.6
109 	 *
110 	 * Throws: ConstructionException GTK+ fails to create the object.
111 	 */
112 	public this(string character)
113 	{
114 		auto __p = gtk_text_child_anchor_new_with_replacement(Str.toStringz(character));
115 
116 		if(__p is null)
117 		{
118 			throw new ConstructionException("null returned by new_with_replacement");
119 		}
120 
121 		this(cast(GtkTextChildAnchor*) __p, true);
122 	}
123 
124 	/**
125 	 * Determines whether a child anchor has been deleted from
126 	 * the buffer.
127 	 *
128 	 * Keep in mind that the child anchor will be unreferenced
129 	 * when removed from the buffer, so you need to hold your own
130 	 * reference (with g_object_ref()) if you plan to use this
131 	 * function — otherwise all deleted child anchors will also
132 	 * be finalized.
133 	 *
134 	 * Returns: %TRUE if the child anchor has been deleted from its buffer
135 	 */
136 	public bool getDeleted()
137 	{
138 		return gtk_text_child_anchor_get_deleted(gtkTextChildAnchor) != 0;
139 	}
140 
141 	/**
142 	 * Gets a list of all widgets anchored at this child anchor.
143 	 *
144 	 * The order in which the widgets are returned is not defined.
145 	 *
146 	 * Returns: an
147 	 *     array of widgets anchored at @anchor
148 	 */
149 	public Widget[] getWidgets()
150 	{
151 		uint outLen;
152 
153 		auto __p = gtk_text_child_anchor_get_widgets(gtkTextChildAnchor, &outLen);
154 
155 		if(__p is null)
156 		{
157 			return null;
158 		}
159 
160 		Widget[] arr = new Widget[outLen];
161 		for(int i = 0; i < outLen; i++)
162 		{
163 			arr[i] = ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p[i]);
164 		}
165 
166 		return arr;
167 	}
168 }